package com.youyi.yyviewsdklibrary.Dialog.core;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import com.youyi.yyviewsdklibrary.Dialog.animator.PopupAnimator;
import com.youyi.yyviewsdklibrary.Dialog.animator.ScaleAlphaAnimator;
import com.youyi.yyviewsdklibrary.Dialog.enums.PopupAnimation;
import com.youyi.yyviewsdklibrary.Dialog.interfaces.OnViewBack;
import com.youyi.yyviewsdklibrary.Dialog.util.XPopupUtils;
import com.lkx.liandianqinew.R;

public class CenterPopupView extends BasePopupView {
    protected int bindItemLayoutId;
    protected int bindLayoutId;
    protected FrameLayout centerPopupContainer = ((FrameLayout) findViewById(R.id.centerPopupContainer));
    protected View contentView;
    protected OnViewBack mOnViewBack;
    protected int realLayout;

    public CenterPopupView(Context context) {
        super(context);
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public void onCreate() {
        super.onCreate();
        OnViewBack onViewBack = this.mOnViewBack;
        if (onViewBack != null) {
            onViewBack.result(new XDialog(this, null), this.contentView);
        }
    }

    public CenterPopupView(Context context, int i, OnViewBack onViewBack) {
        super(context);
        this.realLayout = i;
        this.mOnViewBack = onViewBack;
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public int getImplLayoutId() {
        return this.realLayout;
    }

    /* access modifiers changed from: protected */
    public void addInnerContent() {
        View inflate = LayoutInflater.from(getContext()).inflate(getImplLayoutId(), (ViewGroup) this.centerPopupContainer, false);
        this.contentView = inflate;
        LayoutParams layoutParams = (LayoutParams) inflate.getLayoutParams();
        layoutParams.gravity = 17;
        this.centerPopupContainer.addView(this.contentView, layoutParams);
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public final int getInnerLayoutId() {
        return R.layout._xpopup_center_popup_view;
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public void initPopupContent() {
        super.initPopupContent();
        if (this.centerPopupContainer.getChildCount() == 0) {
            addInnerContent();
        }
        getPopupContentView().setTranslationX((float) this.popupInfo.offsetX);
        getPopupContentView().setTranslationY((float) this.popupInfo.offsetY);
        XPopupUtils.applyPopupSize((ViewGroup) getPopupContentView(), getMaxWidth(), getMaxHeight(), getPopupWidth(), getPopupHeight(), null);
    }

    /* access modifiers changed from: protected */
    public void applyTheme() {
        if (this.bindLayoutId != 0) {
            return;
        }
        if (this.popupInfo.isDarkTheme) {
            applyDarkTheme();
        } else {
            applyLightTheme();
        }
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public void applyDarkTheme() {
        super.applyDarkTheme();
        this.centerPopupContainer.setBackground(XPopupUtils.createDrawable(getResources().getColor(R.color._xpopup_dark_color), this.popupInfo.borderRadius));
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public void applyLightTheme() {
        super.applyLightTheme();
        this.centerPopupContainer.setBackground(XPopupUtils.createDrawable(getResources().getColor(R.color._xpopup_light_color), this.popupInfo.borderRadius));
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        setTranslationY(0.0f);
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public int getMaxWidth() {
        if (this.popupInfo.maxWidth == 0) {
            return (int) (((float) XPopupUtils.getAppWidth(getContext())) * 0.8f);
        }
        return this.popupInfo.maxWidth;
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public PopupAnimator getPopupAnimator() {
        return new ScaleAlphaAnimator(getPopupContentView(), getAnimationDuration(), PopupAnimation.ScaleAlphaFromCenter);
    }
}
